<template>
  <div class="realmarket">
    <div class="header">
      <van-icon name="arrow-left" @click="this.$router.go(-1)" />
      <li>楼市圈</li>
      <span></span>
    </div>
    <main>
      <div class="list">
        <div class="real" v-for="v in realList" :key="v.id">
          <li class="user">
            <img :src="v.userImg" alt="" />
            <p>{{ v.name }}</p>
          </li>
          <div class="house">
            <div class="date">{{ v.date }}</div>
            <div class="roomImg">
              <li>{{ v.title }}</li>
              <li><img :src="v.img" alt="" /></li>
              <li><button @click="delRealmarket(v.id)">删除</button></li>
            </div>
          </div>
        </div>
      </div>
    </main>
    <div
      class="addhouse"
      @click="
        () => {
          this.$router.push('/issue');
        }
      "
    >
      <van-icon name="plus" />
    </div>
  </div>
</template>

<script>
import axios from "../../util/axios";
export default {
  data() {
    return {
      realList: [],
    };
  },
  created() {
    this.getRealmarket();
  },
  methods: {
    getRealmarket() {
      axios.get("/getMarket").then((res) => {
        console.log(res);
        this.realList = res.data.data;
        console.log(this.realList);
      });
    },
    delRealmarket(id) {
      axios.post("/deleteMark", { id: id }).then((res) => {
        console.log(res);
        this.getRealmarket();
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.realmarket {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}
.header {
  width: 100%;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  background: cornflowerblue;
  color: #fff;
}
main {
  width: 100%;
  flex: 1;
  overflow-y: scroll;
  .list {
    width: 100%;
    height: 100%;
    .real {
      width: 100%;
      padding: 5px 10px;
      > li {
        width: 100%;
        height: 50px;
        display: flex;
        align-items: center;
        margin-top: 10px;
        img {
          width: 50px;
          height: 50px;
          border-radius: 50%;
          margin-right: 15px;
        }
      }
      .house {
        width: 100%;
        display: flex;
        overflow: hidden;
        margin-top: 10px;
        .date {
          width: 50px;
          margin-right: 15px;
        }
        .roomImg {
          flex: 1;
          img {
            width: 100%;
            height: 200px;
            margin-top: 5px;
          }
          :nth-child(3) {
            width: 100%;
            height: 30px;
            line-height: 30px;
            text-align: center;
            button {
              border: none;
              outline: none;
              background: none;
              color: cornflowerblue;
            }
          }
        }
      }
    }
  }
}
.addhouse {
  width: 50px;
  height: 50px;
  position: fixed;
  top: 80%;
  right: 10px;
  text-align: center;
  line-height: 50px;
  border-radius: 50%;
  background: cornflowerblue;
  color: #fff;
  font-size: 25px;
}
</style>